import request from '@/router/axios';

export const getList = (page, size, params) => {
	return request({
		url: '/cards/coupon/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
export const remove = (id) => {
	return request({
		url: '/cards/coupon/delete',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			id,
		}
	})
}
//查看详情
export const getInfo = (page, size,params) => {
	return request({
		url: '/cards/couponInfo/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
//优惠券发放
export const sendSave = (id,type,users) => {
	return request({
		url: '/cards/coupon/couponSendSave',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			id,
			type,
			users
		}
	})
}
//优惠券可用商品
export const getGoods = (couponId) => {
	return request({
		url: '/cards/couponGoods/list',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			couponId,
		}
	})
}
export const add = (row) => {
	return request({
		url: '/cards/coupon/addItem',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: row
	})
}

export const update = (row) => {
	return request({
		url: '/cards/coupon/editItem',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: row
	})
}

export const detail = (row) => {
	return request({
		url: '/cards/coupon/detail',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: row
	})
}

export const getListGoods = (row) => {
	return request({
		url: '/base/goodsManage/listGoods',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: row
	})
}
//优惠券领取详情
export const getCouponD = (id) => {
	return request({
		url: '/base/coupon/changeStatus',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			id
		}
	})
}

export const changeStatus = (userId, status) => {
	return request({
		url: '/base/coupon/changeStatus',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			userId,
			status
		}
	})
}
export const couponSendSave = (id, params) => {
	return request({
		url: '/base/coupon/couponSendSave',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		params: {
			id,
			...params,
		}
	})
}
//根据下拉id获取商品
export const getGoodsList = (page,size,params) => {
	return request({
		url: '/cards/couponGoods/list',
		method: 'post',
		params: {
			...params,
			page,
			size,
		}
	})
}
export const getlistManageByAccount = (account) => {
	return request({
		url: '/cards/cardUser/listManageByAccount',
		method: 'post',
		meta: {
			isSerialize: true,
		},
		data: {
			account
		}
	})
}

export const updateDisplay = (id, couponStatus) => {
	// 这里classDisplay如果是boolean类型,无法传入后台,待以后优化吧
	return request({
		url: "/cards/coupon/editItem",
		method: "post",
		meta: {
			isSerialize: true
		},
		data: {
			id,
			couponStatus
		}
	});
};